using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using GoodStuff;
using Prosilica;

namespace Octopus111
{
    class GoodTimer : GoodConvertibleVariable<Decimal>
    {
        Timer _timer;
        public ICamera CameraInstance;

        public GoodTimer()
        {
            _timer = new Timer();
            _timer.Tick += TickHandler;
            ValueChanged += OnIntervalChanged;
        }

        public void Start()
        {
            _timer.Interval = (int)Value;
            _timer.Start();
        }

        public void Stop()
        {
            _timer.Stop();
        }

        public void OnIntervalChanged(object sender, EventArgs args)
        {
            _timer.Stop();
            _timer.Interval = (int)Value;
            _timer.Start();
        }

        void TickHandler(object sender, EventArgs args)
        {
            CameraInstance.TriggerShot();
        }
    }
}
